package com.meilele.dao.zhengchao;

import com.meilele.entity.zhengchao.FourArticle;
import com.meilele.entity.zhengchao.FourArticleVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface FourArticleMapper {
    @Delete({
        "delete from four_article",
        "where article_id = #{articleId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer articleId);

    @Insert({
        "insert into four_article (article_id, article_title, ",
        "article_type, article_small_title, ",
        "article_image, content_id, ",
        "article_upload_data, article_head)",
        "values (#{articleId,jdbcType=INTEGER}, #{articleTitle,jdbcType=VARCHAR}, ",
        "#{articleType,jdbcType=VARCHAR}, #{articleSmallTitle,jdbcType=VARCHAR}, ",
        "#{articleImage,jdbcType=VARCHAR}, #{contentId,jdbcType=INTEGER}, ",
        "#{articleUploadData,jdbcType=TIMESTAMP}, #{articleHead,jdbcType=VARCHAR})"
    })
    int insert(FourArticleVO record);

    int insertSelective(FourArticle record);

    @Select({
        "select",
        "article_id, article_title, article_type, article_small_title, article_image, ",
        "content_id, article_upload_data, article_head,article_reader",
        "from four_article",
        "where article_id = #{articleId,jdbcType=INTEGER}"
    })
    @ResultMap("com.meilele.dao.zhengchao.FourArticleMapper.BaseResultMap")
    FourArticle selectByPrimaryKey(Integer articleId);

    int updateByPrimaryKeySelective(FourArticleVO record);

    @Update({
        "update four_article",
        "set article_title = #{articleTitle,jdbcType=VARCHAR},",
          "article_type = #{articleType,jdbcType=VARCHAR},",
          "article_small_title = #{articleSmallTitle,jdbcType=VARCHAR},",
          "article_image = #{articleImage,jdbcType=VARCHAR},",
          "content_id = #{contentId,jdbcType=INTEGER},",
          "article_upload_data = #{articleUploadData,jdbcType=TIMESTAMP},",
          "article_head = #{articleHead,jdbcType=VARCHAR}",
        "where article_id = #{articleId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(FourArticle record);
    @Select("select article_id,article_title,article_type,article_small_title,article_image,content_id,article_upload_data,article_head from four_article where article_type = #{cc} limit #{haha},#{xixi}")
    @ResultMap("com.meilele.dao.zhengchao.FourArticleMapper.BaseResultMap")
    List<FourArticle> findArticleByType( @Param("cc") Integer cc,@Param("haha") Integer aa, @Param("xixi") Integer bb);
    @Select("select article_id,article_title,article_type,article_small_title,article_image,content_id,article_upload_data,article_head from four_article limit #{haha},#{xixi}")
    @ResultMap("com.meilele.dao.zhengchao.FourArticleMapper.BaseResultMap")
    List<FourArticle> findAll(@Param("haha") Integer aa, @Param("xixi") Integer bb);
    @Select("select count(article_id) from four_article where article_type = #{id} ")
    int getCount(int id);
    @Select("select count(article_id) from four_article  ")
    int getCount1();
    @Select("SELECT article_id,article_title,article_type,article_small_title,article_image,content_id,article_upload_data,article_head,article_reader from four_article order By article_reader DESC limit 8")
    @ResultMap("com.meilele.dao.zhengchao.FourArticleMapper.BaseResultMap")
    List<FourArticle> orderByReader();
    @Select("SELECT article_id,article_title,article_type,article_small_title,article_image,content_id,article_upload_data,article_head,article_reader from four_article order By article_upload_data DESC limit #{aa},#{bb}")
    @ResultMap("com.meilele.dao.zhengchao.FourArticleMapper.BaseResultMap")
   List<FourArticle> orderByTime(@Param("aa") int pageNum,@Param("bb") int pageNumber);
    @Update("update four_article set article_reader =#{bb} where article_id=#{aa}")
    void updateReadById(@Param("aa") int id, @Param("bb") Integer bb);
}